﻿using UnityEngine;

namespace TC
{
    public class MoveTo_blueprint : TranslateBlueprint
    {
        public override editor.cfg.blueprint.Node OnTranslate(Node node)
        {
            MoveTo t = node as MoveTo;
            editor.cfg.blueprint.MoveTo re = new editor.cfg.blueprint.MoveTo();
            re.id = t.id;
            re.waitFinish = t.wait;
            Port p = t.graph.GetConnect(t.target);
            if(p != null)
            {
                re.gameObject = new editor.cfg.blueprint.OutputPin() { nodeId = p.parent.id, pinName = p.name };
            }
            p = t.graph.GetConnect(t.dest);
            if(p == null)
            {
                Vector3 v = t.dest.defaultValue;
                re.target = new editor.cfg.blueprint.ConstVector3() { value = new editor.cfg.map.Vector3() { x = v.x, y = v.y, z = v.z } };
            }
            else
            {
                re.target = new editor.cfg.blueprint.OutputPin() { nodeId = p.parent.id, pinName = p.name };
            }

            return re;
        }
    }
}
